<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no" />
		<title>速翔网络</title>
		<link rel="stylesheet" type="text/css" href="../c/aui.css" />
		<style>
			body{
				background: #fff;
				color: #222;
			}
			#sx-header{

			}
			.aui-btn img{
				width: 1rem;
				transform: rotate(180deg);
				-webkit-transform: rotate(180deg);
			}
			.nav{
				background: #ddd;
				height: 2rem;
			}
		</style>
	</head>
	<body>
		<header class="aui-bar aui-bar-nav" id="sx-header">
			<a class="aui-pull-left aui-btn" tapmode onclick="_close()"><img src="../i/right-bai.png" /></a>
			<div class="aui-title">商品列表</div>
		</header>
		<div class="nav">

		</div>
	</body>
	<script type="text/javascript" src="../j/api.js"></script>
	<script type="text/javascript">
		var NVNavigationBar,header,typeid_data
		apiready = function() {
			header = $api.byId('sx-header');
			$api.fixStatusBar(header);
			NVNavigationBar = api.require('NVNavigationBar');
			typeid_data = _getPrefs('_config').typeid;
			type();
		}
		// 中间分类
		function type() {
			NVNavigationBar.open({
				rect : {
					x : 0,
					y : $api.offset(header).h,
					w : api.winWidth,
					h : $('.nav').height()
				},
				styles : {
					orientation : 'horizontal',
					bg : '#F0F0F0',
					bgAlpha : 1,
					font : {
						size : 14,
						sizeSelected : 16,
						color : '#333',
						colorSelected : '#FF2D4B',
						alpha : 1
					},
					itemSize : {
						w : 75,
						h : $('.nav').height()
					},
					bounces : true,
				},
				items : typeid_data.a,
				selectedIndex : 0,
				fixedOn : api.frameName,
				id : 'shop'
			}, function(ret, err) {
				if (ret.eventType == 'click') {
					api.setFrameGroupIndex({
						name : 'shop',
						index : ret.index,
						scroll : true, //是否平滑滚动至目标窗口，即是否带有动画
					});
				}
			});

			var frames = [];
			for (var i = 0; i < typeid_data.b.length; i++) {
				var frame = {};
				frame.name = 'shop_' + i;
				frame.url = _h_w + 'shop.html';
				frame.pageParam = {
					i : i,
					typeid:typeid_data.b[i]
				};
				frames.push(frame);
			}
			openFrameGroup(frames)
		}
		function openFrameGroup(frames) {
			// console.log(JSON.stringify(frames))
			var headerPos = $api.offset(header);
			var body_h = api.frameHeight;
			asdasd = body_h - headerPos.h -  $('.nav').height()
			api.openFrameGroup({
				name : 'shop',
				scrollEnabled : true,
				bounces : true,
				rect : {
					x : 0,
					y : headerPos.h +  $('.nav').height(),
					w : 'auto',
					h : asdasd,
				},
				index : 0,
				frames : frames,
				preload : 0,	// 预加载的 frame 个数，默认加载当前页后面一个
			}, function(ret, err) {
				// var index = ret.index;
				NVNavigationBar.setSelected({
					id : 'shop',
					index : ret.index,
					selected : true
				});
				//active(index)
			});
		}
	</script>
</html>
